package com.qeeyou.apps.android.craftsman.view;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.qeeyou.apps.android.craftsman.R;

/**
 * Created by xuchengxiong on 2017/3/8.
 */

public class CustomLoadingDialog extends Dialog {

    private ProgressBar mProgressBar;
    private TextView txtvMessage;

    public CustomLoadingDialog(Context context) {
        super(context, R.style.loading_dialog);
        setView();
    }

    private void setView() {
        View view = LayoutInflater.from(getContext()).inflate(R.layout.view_custom_loading_dialog, null);
        mProgressBar = (ProgressBar) view.findViewById(R.id.progressBar4CustomLoadingDialog);
        txtvMessage = (TextView) view.findViewById(R.id.txtvMessage4CustomLoadingDialog);
        setContentView(view);
        WindowManager.LayoutParams params = getWindow().getAttributes();
        params.width = WindowManager.LayoutParams.WRAP_CONTENT;
        params.height = WindowManager.LayoutParams.WRAP_CONTENT;
        getWindow().setAttributes(params);

        setCancelable(false);
        setCanceledOnTouchOutside(false);
    }

    public void setMessage(CharSequence message) {
        txtvMessage.setText(message);
    }

    @Override
    public void show() {
        super.show();
    }

    @Override
    public void dismiss() {
        super.dismiss();
    }
}
